package com.zzxx.mapper;

import com.zzxx.entity.UserCoupon;
import com.zzxx.entity.UserCouponExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface UserCouponMapper {
    @SelectProvider(type=UserCouponSqlProvider.class, method="countByExample")
    long countByExample(UserCouponExample example);

    @DeleteProvider(type=UserCouponSqlProvider.class, method="deleteByExample")
    int deleteByExample(UserCouponExample example);

    @Delete({
        "delete from usercoupon",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String id);

    @Insert({
        "insert into usercoupon (id, userId, ",
        "couponId, activeTime, ",
        "status)",
        "values (#{id,jdbcType=VARCHAR}, #{userid,jdbcType=VARCHAR}, ",
        "#{couponid,jdbcType=VARCHAR}, #{activetime,jdbcType=DATE}, ",
        "#{status,jdbcType=INTEGER})"
    })
    int insert(UserCoupon row);

    @InsertProvider(type=UserCouponSqlProvider.class, method="insertSelective")
    int insertSelective(UserCoupon row);

    @SelectProvider(type=UserCouponSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="userId", property="userid", jdbcType=JdbcType.VARCHAR),
        @Result(column="couponId", property="couponid", jdbcType=JdbcType.VARCHAR),
        @Result(column="activeTime", property="activetime", jdbcType=JdbcType.DATE),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER)
    })
    List<UserCoupon> selectByExample(UserCouponExample example);

    @Select({
        "select",
        "id, userId, couponId, activeTime, status",
        "from usercoupon",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="userId", property="userid", jdbcType=JdbcType.VARCHAR),
        @Result(column="couponId", property="couponid", jdbcType=JdbcType.VARCHAR),
        @Result(column="activeTime", property="activetime", jdbcType=JdbcType.DATE),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER)
    })
    UserCoupon selectByPrimaryKey(String id);

    @UpdateProvider(type=UserCouponSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("row") UserCoupon row, @Param("example") UserCouponExample example);

    @UpdateProvider(type=UserCouponSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("row") UserCoupon row, @Param("example") UserCouponExample example);

    @UpdateProvider(type=UserCouponSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(UserCoupon row);

    @Update({
        "update usercoupon",
        "set userId = #{userid,jdbcType=VARCHAR},",
          "couponId = #{couponid,jdbcType=VARCHAR},",
          "activeTime = #{activetime,jdbcType=DATE},",
          "status = #{status,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(UserCoupon row);
}